var g, _extends = Object.assign || function(t) {
    for (var e = 1; e < arguments.length; e++) {
        var a, n = arguments[e];
        for (a in n) Object.prototype.hasOwnProperty.call(n, a) && (t[a] = n[a]);
    }
    return t;
}, _tools = require("../../../utils/tools"), app = getApp(), page = app.page, request = app.util.request, route = app.route, toast = app.toast;

function getWendaInfo(t) {
    request({
        url: "InformationCenterInfo",
        data: {
          center_id: t
        },
        success: function(t) {
            g.setData(_extends({}, t)), wx.stopPullDownRefresh();
        }
    });
}

page({
    data: {
        no_data: app.srcRoot + "no_data.png",
        user_img: app.srcRoot + "user.png"
    },
    onLoad: function(t) {
        g = this, getWendaInfo(t.id), g.setData({
            islaw: wx.getStorageSync("page")
        });
    },
    onShow: function() {
        getWendaInfo(this.options.id);
    },
    onPullDownRefresh: function() {
        getWendaInfo(this.options.id);
    },
    viewImg: function(t) {
        wx.previewImage({
            urls: g.data.imglist,
            current: t.currentTarget.dataset.index
        });
    },
    huifu: function(t) {
        // for (var t = 0; t < g.data.list.length; t++) if (g.data.list[t].law.user_id == g.data.userInfo.id) return toast("您已回复过,\n无法再次回复");
        let cid = t.currentTarget.dataset.cid || ''
        wx.navigateTo({
          url: '/u_pages/message/huifu/index?id=' + g.data.id + "&cid=" + cid,
        })
        // route({
        //     type: "navigate",
        //     url: "message_huifu",
        //     params: {
        //         id: g.data.id
        //     }
        // });
    },
    viewLay: function(t) {
        route({
            type: "navigate",
            url: "lawyer_info",
            params: {
                id: t.currentTarget.dataset.id
            }
        });
    },
    caina: function(e) {
        wx.showModal({
            title: "提示",
            cancelText: "取消",
            confirmText: "确认采纳",
            confirmColor: g.data.system.foot_color2,
            content: "一经采纳" + (g.data.system.wenda.sj_title || "赏金") + "将会支付给" + g.data.system.law_custom + "\n不可再采纳其他的回答\n您确定采纳吗？",
            success: function(t) {
                return t.confirm && request({
                    url: "QuestionCaina",
                    data: {
                        question_id: g.data.id,
                        answer_id: e.currentTarget.dataset.id
                    },
                    success: function(t) {
                        getWendaInfo(g.options.id);
                    }
                });
            }
        });
    }
});